﻿using LmgCMS.Model;
using LmgCMS.Service;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Swagger;

namespace LmgCMS.Areas.API.Controllers {
    /// <summary>
    /// 任务管理
    /// </summary>
    [ApiExplorerSettings(GroupName = SwaggerGroupingModel.GROUPNAME_COMM)]
    public class OpenJobController : BaseController<OpenJob>
    {
        private readonly IOpenJobService _jobService;
        public OpenJobController(IOpenJobService jobService)
        {
            _jobService = jobService;
        }
        /// <summary>
        /// 获取本地可执行的任务列表
        /// </summary>
        [HttpPost]
        public IActionResult QueryLocalHandlers()
        {
            return Success("获取本地可执行的任务列表", _jobService.QueryLocalHandlers());
        }
        /// <summary>
        /// 改变任务状态，启动/停止
        /// </summary>
        [HttpPost]
        public IActionResult ChangeStatus(ChangeJobStatusReq req)
        {
            _jobService.ChangeJobStatus(req);
            return Success("改变任务状态");
        }
    }
}
